package com.googlecode.project4uz.tests;

import static org.junit.Assert.*;



import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.Collection;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.openrdf.rio.RDFFormat;

import com.googlecode.project4uz.decoder.RioReader;
import com.googlecode.project4uz.demo.BeanTestClass;
import com.googlecode.project4uz.demo.ClassForSerialize;
import com.googlecode.project4uz.demo.SimpleClassForSerialize;
import com.googlecode.project4uz.demo.TestHardcoreClass;


@RunWith(Parameterized.class)
public class RDFDecoderTest {
	private RioReader rdf;
	RDFFormat format;
	String nazwa;

	

	public RDFDecoderTest( RDFFormat c, String d) {

		
		this.format = c;
		this.nazwa = d;
	
	}

	@Parameters
	public static Collection<Object[]> prepareConstructor() {

		return Arrays
				.asList(new Object[][] {
					{RDFFormat.RDFXML, "test.rdf" },
					{RDFFormat.RDFXML, "test2.rdf" },
					{RDFFormat.RDFXML, "test2.rdf" },
					{RDFFormat.RDFXML, "test3.rdf" },
					{RDFFormat.RDFXML, "test4.rdf" },
					{RDFFormat.RDFXML, "test5.rdf" },
					{RDFFormat.RDFXML, "test6.rdf" },
					{null, "test.rdf" },
					{RDFFormat.RDFXML, null },
				});
	}

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	rdf=new RioReader(format,new BufferedInputStream(new FileInputStream(nazwa)));
	}

	@After
	public void tearDown() throws Exception {
		rdf=null;
	}

	@Test
	public void testRioReader() {
		assertNotNull("Obiekt nie istnieje", rdf);
	}
	public void testReadObject() {
		Object a=rdf.readObject();
		SimpleClassForSerialize s;
		ClassForSerialize c;
		BeanTestClass b;
		TestHardcoreClass h;
		if(a instanceof SimpleClassForSerialize)
		s = (SimpleClassForSerialize)a;
		else if(a instanceof BeanTestClass)
		b=(BeanTestClass)a;
		else if(a instanceof TestHardcoreClass)
		h=(TestHardcoreClass)a;
		else if(a instanceof ClassForSerialize)
		c=(ClassForSerialize)a;
	}
	
	
	
}
